package com.example.aircraftticketingsystemserver.service.impl;

import com.example.aircraftticketingsystemserver.entity.Ticket;
import com.example.aircraftticketingsystemserver.mapper.FlightsMapper;
import com.example.aircraftticketingsystemserver.mapper.TicketMapper;
import com.example.aircraftticketingsystemserver.service.ITicketService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lxz
 * @since 2024-08-19
 */
@Service
public class TicketServiceImpl extends ServiceImpl<TicketMapper, Ticket> implements ITicketService {
    @Resource
    private TicketMapper ticketMapper;

    @Resource
    private FlightsMapper flightsMapper;

    @Override
    public void updateTicket(Ticket ticket) {
        ticketMapper.updateTicket(ticket);
    }

    @Override
    public List<Ticket> selectTicketByFlightId(Integer flightId) {
        List<Ticket> tickets = ticketMapper.selectTicketByFlightId(flightId);
        return tickets;
    }

    @Override
    public void deleteTicketByTicketId(Integer ticketId) {
        ticketMapper.deleteTicketByTicketId(ticketId);
    }

    @Override
    public void addTicket(Ticket ticket) {
        flightsMapper.addTicketByFlightId(ticket);
    }

    @Override
    public Ticket selectTicketByTicketId(Integer ticketId) {
        return ticketMapper.selectById(ticketId);
    }
}
